# -*- coding: utf-8 -*-
# @Time : 2023/12/10 22:51
# @Author : Lpb
# @File : pro1.py

# 2）找出便签valid不为0的noteId
res = {
    "responseTime": 36,
    "noteBodies": [
        {
            "summary": "K+7KGjCoDl3fIwnxXfQPIQ==",
            "noteId": "458114392903b8e164f1d583fb63b949",
            "infoNoteId": "458114392903b8e164f1d583fb63b949",
            "bodyType": 0,
            "body": "Arrvft6YZvdqji9HTZ0TLgpzU2a4zB/Nz+qJR0NWdIM=",
            "contentVersion": 1,
            "contentUpdateTime": 1686818813994,
            "title": 'null',
            "valid": 0
        },
        {
            "summary": "K+7KGjCoDl3fIwnxXfQPIQ==",
            "noteId": "458114392903b8e164f1d583fb6b9123",
            "infoNoteId": "458114392903b8e164f1d583fb63b949",
            "bodyType": 0,
            "body": "Arrvft6YZvdqji9HTZ0TLgpzU2a4zB/Nz+qJR0NWdIM=",
            "contentVersion": 1,
            "contentUpdateTime": 1686818813999,
            "title": 'null',
            "valid": 0
        },
        {
            "summary": "K+7KGjCoDl3fIwnxXfQPIQ==",
            "noteId": "458114392903b52844f1d583fb63b949",
            "infoNoteId": "458114392903b8e164f1d583fb63b949",
            "bodyType": 0,
            "body": "Arrvft6YZvdqji9HTZ0TLgpzU2a4zB/Nz+qJR0NWdIM=",
            "contentVersion": 1,
            "contentUpdateTime": 1686818813996,
            "title": 'null',
            "valid": 1
        },
        {
            "summary": "K+7KGjCoDl3fIwnxXfQPIQ==",
            "noteId": "458114392903b8e1641123fb63b949",
            "infoNoteId": "458114392903b8e164f1d583fb63b949",
            "bodyType": 0,
            "body": "Arrvft6YZvdqji9HTZ0TLgpzU2a4zB/Nz+qJR0NWdIM=",
            "contentVersion": 1,
            "contentUpdateTime": 1686818813992,
            "title": 'null',
            "valid": 0
        }
    ]
}
# 1)找出所有便签的contentUpdateTime并按照从早到晚的顺序排列输出列表
content_update_times = []

for note in res["noteBodies"]:
    content_update_time = note["contentUpdateTime"]
    content_update_times.append(content_update_time)
    for i in range(len(content_update_times) - 1):
        for j in range(len(content_update_times) - 1 - i):
            if content_update_times[j] > content_update_times[j + 1]:
                content_update_times[j], content_update_times[j + 1] = content_update_times[j + 1], content_update_times[j]

print(content_update_times)


# 2）找出便签valid不为0的noteId
note_ids = []
for note in res["noteBodies"]:
    valid1 = note["valid"]
    note_id = note["noteId"]
    if note['valid'] != 0:
        note_ids.append(note_id)
print(note_ids)

